package reflect;

/**
 * 可变长参数(应对方法参数的个数不固定所带来的问题)
 */
public class ArgDemo {
    public static void main(String[] args) {
        dosome("1");
        dosome("1","2");
        dosome("1","2","3");
        dosome("1","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3","2","3");
        dosome();
    }
    /*
        变长参数的语法要求:一个方法中只能有一个变长参数,且是最后一个参数
     */
    public static void dosome(String... arg){
        //变长参数本身就是一个数组
        System.out.println(arg.length);
    }
}






